package com.example.demo;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author Admin
 */
@SpringBootApplication()
//@MapperScan("com.*.*.mapper")

@Slf4j
@EnableScheduling //开启定时任务
public class SqldemosApplication {

	public static void main(String[] args) throws UnknownHostException {
		ConfigurableApplicationContext application = SpringApplication.run(SqldemosApplication.class, args);
		Environment env = application.getEnvironment();
		String hostAddr=InetAddress.getLocalHost().getHostAddress();
		String port=env.getProperty("server.port", "8080");
		log.info("\n-----------------------------------------------------------------\n\t" +
						"应用 '{}' 启动成功! 访问连接:\n" +
						"\tSwagger文档: \t\thttp://{}:{}/doc.html\n" +
						"\t数据库监控druid: \t\thttp://{}:{}/druid\n" +
						"\t主页: \t\thttp://{}:{}/index\n" +
				 "-----------------------------------------------------------------",
				env.getProperty("spring.application.name"),
				hostAddr,port,
				hostAddr,port,
				hostAddr,port
		);
	}

	@Bean
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}




}
